<template>
  <el-form :model="form" label-width="120px">
   <el-tabs type="border-card" class="demo-tabs">
      <el-tab-pane>
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><calendar /></el-icon>
            <span>基础</span>
          </span>
        </template> 
            <JmInput  jmname="标题" v-model="form.title"   type="text"  ></JmInput>
            <JmInput  jmname="作者" v-model="form.author"   type="text"  ></JmInput>
            <JmInput  jmname="标记" v-model="form.flag"   type="text"  ></JmInput>
            <JmInput  jmname="链接" v-model="form.art_link"   type="text"  ></JmInput>

           <JmEnum jmname="推荐" v-model="form.is_recommend" :jv="{1: '是', 0: '否'}" jtype="2"  ></JmEnum>
           <JmEnum jmname="最新" v-model="form.is_news" :jv="{1: '是', 0: '否'}" jtype="2"  ></JmEnum>
           
           <JmEnum jmname="栏目id" v-model="form.cate_id" :jv="cate" jtype="4"  ></JmEnum>
<!--        

parent_path  
delete_time
create_time
update_time  
 
   --> 

      </el-tab-pane>



      <el-tab-pane label="图片">
       
           <JmInput type="img" jmname="缩略图" v-model="form.art_img"></JmInput> 
           <JmInput type="img" jmname="大图" v-model="form.art_img_big"></JmInput> 
           <JmInput type="img" jmname="组图" v-model="form.art_img_more"></JmInput>  
  


      </el-tab-pane>

      <el-tab-pane label="seo">
        <JmInput  jmname="seo标题"  v-model="form.seo" ></JmInput>

        <JmInput jmname="关键词"  v-model="form.keywords"   type="textarea"   ></JmInput>

        <JmInput jmname="seo描述"  v-model="form.description"   type="textarea" ></JmInput>
  
      </el-tab-pane>
      
      
      <el-tab-pane label="内容">
         
            <JmInput type="textarea" jmname="摘要" v-model="form.abstract"></JmInput>
            <JmInput type="textarea" jmname="内容" v-model="form.content"></JmInput>
  
      </el-tab-pane>
      
   

      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button> 
      </el-form-item>
    </el-tabs>
            
 
  </el-form>
</template>
 
<script>
import JmInput from "../../../components/form/JmInput.vue";
import JmEnum from "../../../components/form/JmEnum.vue";
export default {
  components: { JmInput, JmEnum },
  data() {
    return {
         form: { 
              cate_id:0,
              parent_path:'',
              title:'',
              author:'',
              abstract:'',
              content:'',
              art_link:'',
              art_img_big:'',
              art_img:'',
              art_img_more:'',
              flag:'',
              views:0,
              seo:'',
              keywords:'',
              description:'简介',
              is_recommend:1, 
              is_news:1,  
 
            },

      cate :{}
    };
  },

  mounted() {
    this.getDataList();
  },
  methods: {
    // 配置信息列表初始化
    async getDataList() {
      try {
       const res = await this.$api.Cate({select:1,cate_model:3}); 
          let ccc={}; 
          res.rows.forEach(element => { 
                ccc[element.id]=element.prefix+element.cate_name;
          }); 
          console.log(ccc,"查询")
          this.cate=ccc; 

      } catch (error) {
        /*console.error(error);*/
      }
    },
    onSubmit() {
      //  console.log(this.form);
      const res = this.$api.addArticle(this.form);
// this.$parent.handleClose();
       
       this.$parent.$parent.$parent.$parent.handleClose();   // 
      console.log(res);
    },
  },
};
</script>
<style>
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
.demo-tabs .custom-tabs-label .el-icon {
  vertical-align: middle;
}
.demo-tabs .custom-tabs-label span {
  vertical-align: middle;
  margin-left: 4px;
}
</style>